<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 双重for循环
        var arr = [1,2,1,3,1,4,5,4,6,4,7,8,7,4,8,8,7]
        console.log(arr);
        for(var i = 0; i<arr.length-1;i++){
            for(var j=i+1;j<arr.length;j++){
                if(arr[i] === arr[j]){
                    arr.splice(j,1)
                    j--
                }
            }
        }
        console.log(arr);

        // 创建对象--来赋值--然后判断是否对象名是否相同，在存储在新的arr1里
        var arr1 = [];
        var obj = {};
        for(var i = 0; i<arr.length;i++){
            if(obj[arr[i]] == undefined){
                obj[arr[i]] = 1;
                arr1.push(arr[i])
            }
        }
        console.log(arr1);

        // ES6新增的方法 New set()
        var arr2 = Array.from(new Set(arr))
        console.log(arr2)
    </script>
</body>
</html>